package com.jetgege.smartbox.Me;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jetgege.smartbox.R;

import static com.jetgege.smartbox.Base.App.mBlueModel;
import static com.jetgege.smartbox.Base.App.mUser;

/**
 * Created by JJT-ssd on 2017/5/6.
 */

public class MeAdpter extends BaseAdapter{

   // String [] itemName ={"修改账号密码","修改盒子密码"};
    String [] itemName ={"修改盒子密码"};
    @Override
    public int getCount() {
        if (mUser.getUserType()==1&&mBlueModel.isConnect()) return itemName.length;
        else return itemName.length-1;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view =null;
        ViewHolder viewHolder =null;
        if (convertView==null){
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.me_list_item,parent,false);
            viewHolder=new ViewHolder();
            viewHolder.iv_ItemIcon = (ImageView)view.findViewById(R.id.iv_ItemIcon);
            viewHolder.tv_ItemName = (TextView)view.findViewById(R.id.tv_ItemName);
            view.setTag(viewHolder);
        }else {
            view=convertView;
            viewHolder =(ViewHolder)view.getTag();
        }
        switch (position){
            case 0:
                viewHolder.iv_ItemIcon.setImageResource(R.drawable.reset_pwd);
                break;
            case 1:
                viewHolder.iv_ItemIcon.setImageResource(R.drawable.reset_device_pwd);
                break;
            default:
                viewHolder.iv_ItemIcon.setImageResource(R.mipmap.ic_launcher);
                break;
        }

        viewHolder.tv_ItemName.setText(itemName[position]);
        return view;
    }

    class ViewHolder{
        ImageView iv_ItemIcon;
        TextView tv_ItemName;
    }
}
